home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
c
/
AmiVoGL_MDEV.lha
/
examples
/
vogl.h
< prev
next >
Wrap
C/C++ Source or Header
|
1997-08-15
|
31KB
|
906 lines
/* vogl.h: */
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#ifdef AZTEC_C
# ifndef AMIGA
# define AMIGA
# endif
#else
# ifdef AMIGA
# ifndef AZTEC_C
# define AZTEC_C
# endif
# endif
#endif
#if defined(PC) || defined(AMIGA) || defined(AZTEC_C)
#include <string.h>
#else
#include <strings.h>
#endif
#ifdef PC /* Stupid pox head crap */
char *vallocate();
char *malloc();
#endif
#if defined(AMIGA) || defined(sgi)
# ifndef __PROTOTYPE__
# define __PROTOTYPE__
# endif
#include "hershey.h"
#endif
/*
* VOGL is always defined if a header file is from the
* VOGL library. In cases where you do use some VOGL
* initialisation routines like vinit, just put #ifdef VOGL...
* around.
*/
#ifndef VOGL
#define VOGL
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/*
* Misc defines...
*/
#define FLAT 0
#define SMOOTH 1
#define GD_XPMAX 1
#define GD_YPMAX 2
/*
* standard colour indices
*/
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7
/*
* when (if ever) we need the precision
*/
#ifdef DOUBLE
#define float double
#endif
/*
* How to convert degrees to radians
*/
#define PI 3.14159265358979
#define D2R (PI / 180.0)
/*
* miscellaneous typedefs and type defines
*/
typedef float Vector[4];
typedef float Matrix[4][4];
typedef float Tensor[4][4][4];
typedef short Angle;
typedef float Coord;
typedef long Icoord;
typedef short Scoord;
// typedef long Object;
typedef short Screencoord;
typedef long Boolean;
typedef unsigned short Device;
typedef unsigned short Colorindex;
/*
* when register variables get us into trouble
*/
#ifdef NOREGISTER
#define register
#endif
/*
* max number of vertices in a ploygon
*/
#define MAXVERTS 128
/*
* object definitions
*/
#define MAXENTS 101 /* size of object table */
#define MAXTOKS 100 /* num. of tokens alloced at once in
an object */
/*
* Polygon fill modes for "polymode"
*/
#define PYM_POINT 0
#define PYM_LINE 0
#define PYM_FILL 1
#define PYM_HOLLOW 1
/*
* functions which can appear in objects
*/
#define ARC 1
#define CALLOBJ 3
#define CIRCLE 5
#define CLEAR 6
#define COLOR 7
#define DRAW 8
#define DRAWSTR 10
#define FONT 12
#define LOADMATRIX 15
#define MAPCOLOR 16
#define MOVE 17
#define MULTMATRIX 18
#define POLY 19
#define POPATTRIBUTES 22
#define POPMATRIX 23
#define POPVIEWPORT 24
#define PUSHATTRIBUTES 25
#define PUSHMATRIX 26
#define PUSHVIEWPORT 27
#define RCURVE 28
#define RPATCH 29
#define SECTOR 30
#define VIEWPORT 33
#define BACKBUFFER 34
#define FRONTBUFFER 35
#define SWAPBUFFERS 36
#define BACKFACING 37
#define TRANSLATE 38
#define ROTATE 39
#define SCALE 40
#define ARCF 41
#define CIRCF 42
#define POLYF 43
#define RECTF 44
#define CMOV 45
/*
* States for bgn* and end* calls
*/
#define NONE 0 /* Just set current spot */
#define VPNT 1 /* Draw dots */
#define VLINE 2 /* Draw lines */
#define VCLINE 3 /* Draw closed lines */
#define VPOLY 4 /* Draw a polygon */
/*
* data types for object tokens
*/
typedef union tk {
char *s;
int i;
float f;
} Token;
typedef struct tls {
int count;
Token *toks;
struct tls *next;
} TokList;
/*
* double buffering modes.
*/
#define SINGLEBUF 1
/*
* attributes
*/
typedef struct {
char backface,
mode; /* Which mode are we in */
int color;
float fontheight;
float fontwidth;
int fontnum;
} Attribute;
/*
* viewport
*/
typedef struct vp {
float left;
float right;
float bottom;
float top;
} Viewport;
/*
* stacks
*/
typedef struct ms { /* Matrix stack entries */
Matrix m;
struct ms *back;
} Mstack;
typedef struct as { /* Attribute stack entries */
Attribute a;
struct as *back;
} Astack;
typedef struct vs { /* Viewport stack entries */
Viewport v;
struct vs *back;
} Vstack;
/*
* vogle device structures
*/
#ifdef AMIGA
typedef struct dev {
char *devname; /* name of device */
char *large, /* name of large font */
*small; /* name of small font */
int (*Vbackb)(void), /* Set drawing in back buffer */
(*Vchar)(char), /* Draw a hardware character */
(*Vcheckkey)(void), /* Ckeck if a key was hit */
(*Vclear)(void), /* Clear the screen to current color */
(*Vcolor)(int), /* Set current color */
(*Vdraw)(int,int), /* Draw a line */
(*Vexit)(void), /* Exit graphics */
(*Vfill)(int,int[],int[]), /* Fill a polygon */
(*Vfont)(char *), /* Set hardware font */
(*Vfrontb)(void), /* Set drawing in front buffer */
(*Vgetkey)(void), /* Wait for and get the next key hit */
(*Vinit)(void), /* Initialise the device */
(*Vlocator)(int *,int*), /* Get mouse/cross hair position */
(*Vmapcolor)(int,int,int,int),/* Set color indicies */
(*Vstring)(char *), /* Draw a hardware string */
(*Vswapb)(void); /* Swap front and back buffers */
} DevEntry;
#else
typedef struct dev {
char *devname; /* name of device */
char *large, /* name of large font */
*small; /* name of small font */
int (*Vbackb)(), /* Set drawing in back buffer */
(*Vchar)(), /* Draw a hardware character */
(*Vcheckkey)(), /* Ckeck if a key was hit */
(*Vclear)(), /* Clear the screen to current color */
(*Vcolor)(), /* Set current color */
(*Vdraw)(), /* Draw a line */
(*Vexit)(), /* Exit graphics */
(*Vfill)(), /* Fill a polygon */
(*Vfont)(), /* Set hardware font */
(*Vfrontb)(), /* Set drawing in front buffer */
(*Vgetkey)(), /* Wait for and get the next key hit */
(*Vinit)(), /* Initialise the device */
(*Vlocator)(), /* Get mouse/cross hair position */
(*Vmapcolor)(), /* Set color indicies */
(*Vstring)(), /* Draw a hardware string */
(*Vswapb)(); /* Swap front and back buffers */
} DevEntry;
#endif
typedef struct vdev {
char initialised,
clipoff,
inobject,
inpolygon,
fill, /* polygon filling */
cpVvalid, /* is the current device position valid */
inbackbuffer, /* are we in the backbuffer */
clipplanes; /* active clipping planes */
void (*pmove)(), /* Polygon moves */
(*pdraw)(); /* Polygon draws */
TokList *tokens; /* ptr 2 list of tokens for current object */
Mstack *transmat; /* top of transformation stack */
Astack *attr; /* top of attribute stack */
Vstack *viewport; /* top of viewport stack */
float hheight, hwidth;/* hardware character height, width */
Vector cpW, /* current postion in world coords */
cpWtrans, /* current world coords transformed */
upvector; /* world up */
int depth, /* # bit planes on screen */
maxVx, minVx,
maxVy, minVy,
sizeX, sizeY, /* size of square on screen */
sizeSx, sizeSy, /* side in x, side in y (# pixels) */
cpVx, cpVy;
DevEntry dev;
float savex, /* Where we started for v*() */
savey,
savez;
char bgnmode; /* What to do with v*() calls */
char save; /* Do we save 1st v*() point */
char *wintitle; /* window title */
char *devname; /* pointer to device name */
Matrix tbasis, ubasis, *bases; /* Patch stuff */
char *enabled; /* pointer to enabled devices mask */
int maxfontnum;
char alreadyread; /* queue device stuff */
char kbdmode; /* are we in keyboard mode */
char mouseevents; /* are mouse events enabled */
char kbdevents; /* are kbd events enabled */
int devno, data;
int concave; /* concave polygons? */
} VDevice;
extern VDevice vdevice; /* device structure */
#define V_X 0 /* x axis in cpW */
#define V_Y 1 /* y axis in cpW */
#define V_Z 2 /* z axis in cpW */
#define V_W 3 /* w axis in cpW */
#ifdef __PROTOTYPE__
void arcprecision(int); /* arcs.c */
void circleprecision(int); /* arcs.c */
void arc( Coord, Coord, Coord, Angle, Angle); /* arcs.c */
void arcs( Scoord, Scoord, Scoord, Angle, Angle);